import request from '@/utils/request'

// 查询退货出库列表
export function listCpmStart(query) {
  return request({
    url: '/output/cpm/list',
    method: 'get',
    params: query,
  })
}

// 查询退货出库详细
export function getCpmStart(CpmId) {
  return request({
    url: '/output/cpm/' + CpmId,
    method: 'get',
  })
}

// 新增成品不良退库头表
export function addCpmStart(data) {
  return request({
    url: '/output/cpm',
    method: 'post',
    data: data,
  })
}

//查询子表明细
export function getCpmStartDetail(order) {
  return request({
    url: '/output/cpm/getDetails/' + order,
    method: 'get',
  })
}

// 修改成品不良退库头表
export function editCpmStart(data) {
  return request({
    url: '/output/cpm',
    method: 'put',
    data: data,
  })
}

//导出头表
export function exportCpm(query) {
  return request({
    url: '/output/cpm/export',
    method: 'get',
    params: query,
  })
}

//导出子表
export function exportCpd(query) {
  return request({
    url: '/output/cpm/exportDetail',
    method: 'get',
    params: query,
  })
}

//获取需要添加的数据
export function getNeedData(query) {
  return request({
    url: '/output/cpm/getNeedData',
    method: 'get',
    params: query,
  })
}

//添加数据
export function addCpd(data) {
  return request({
    url: '/output/cpm/addCpd',
    method: 'post',
    data: data,
  })
}

//删除子项明细
export function deleteCpmStartDetail(order, wldm) {
  return request({
    url: '/output/cpm/removeCpd/' + order + '/' + wldm,
    method: 'delete',
  })
}

//编辑不良原因
export function editCpd(data) {
  return request({
    url: '/output/cpm/editReasonForCpd',
    method: 'put',
    data: data,
  })
}

// 删除退货出库
export function delCpmStart(CpmDjbhs) {
  return request({
    url: '/output/cpm/' + CpmDjbhs,
    method: 'delete',
  })
}

// 提交单据
export function submitCpm(CpmDjbhs) {
  return request({
    url: '/output/cpm/submitCpm/' + CpmDjbhs,
    method: 'put',
  })
}

// 导出退货出库
export function exportCpmStart(query) {
  return request({
    url: '/output/cpm/export',
    method: 'get',
    params: query,
  })
}

// 修改退货出库
export function updateCpmStart(data) {
  return request({
    url: '/output/cpm',
    method: 'put',
    data: data,
  })
}

//厂商确认、批量厂商确认
export function vToConfirm(CpmDjbhs, CpmThCs, CpmThrq) {
  return request({
    url: '/output/cpm/vToConfirm/' + CpmDjbhs + '/' + CpmThCs,
    method: 'put',
  })
}
//审核单据
export function checkCpm(CpmDjbhs) {
  return request({
    url: '/output/cpm/checkCpm/' + CpmDjbhs,
    method: 'put',
  })
}
export function checkBackCpm(CpmDjbhs, backReson) {
  return request({
    url: '/output/cpm/checkBackCpm/' + CpmDjbhs + '/' + backReson,
    method: 'put',
  })
}
export function permitBackCpm(CpmDjbhs) {
  return request({
    url: '/output/cpm/permitBackCpm/' + CpmDjbhs,
    method: 'put',
  })
}
export function permitCpm(CpmDjbhs) {
  return request({
    url: '/output/cpm/permitCpm/' + CpmDjbhs,
    method: 'put',
  })
}
export function postCpm(data) {
  return request({
    url: '/output/cpm/post',
    method: 'put',
    data,
  })
}
export function finishBackCpm(CpmDjbhs) {
  return request({
    url: '/output/cpm/finishBackCpm/' + CpmDjbhs,
    method: 'put',
  })
}

export function CpmReportList(query) {
  return request({
    url: '/output/cpm/CpmReportList',
    method: 'get',
    params: query,
  })
}
export function CpmReportExcel(query) {
  return request({
    url: '/output/cpm/CpmReportExcel',
    method: 'get',
    params: query,
  })
}

export function oneClickOut(order) {
  return request({
    url: `/output/cpm/oneClickOut/${order}`,
    method: 'put',
  })
}
export function outputConfirm(order, wldm, count) {
  return request({
    url: `/output/cpm/outputConfirm/${order}/${wldm}/${count}`,
    method: 'put',
  })
}
export function consolidationOfDocuments() {
  return request({
    url: `/output/cpm/consolidationOfDocuments`,
    method: 'post',
  })
}

export function cpmReportList(query) {
  return request({
    url: '/output/cpm/cpmReportList',
    method: 'get',
    params: query,
  })
}

export function cpmReportExcel(query) {
  return request({
    url: '/output/cpm/cpmReportExcel',
    method: 'get',
    params: query,
  })
}
